package com.ebupt.migu.music.propagate.controller;

import com.ebupt.migu.music.common.auth.IDAuthUtils;
import com.ebupt.migu.music.common.entity.ResultObject;
import com.ebupt.migu.music.common.util.ReqestParamUtil;
import com.ebupt.migu.music.propagate.service.PropagateApproveService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.Map;

@Slf4j
@RestController
@RequestMapping("/propagate/approve")
public class PropagateApproveController {

    @Resource
    private PropagateApproveService propagateApproveService;

    @Autowired
    private HttpServletRequest request;


    @Autowired
    private IDAuthUtils idAuthUtils;

    /**
     * 查询策略审批列表
     *
     * @return
     */
    @RequestMapping("/list")
    public ResultObject queryApproveList() {
        Map<String, Object> params = ReqestParamUtil.getParamsWithUserInfo(request);
        // 是否超级管理员
        params = idAuthUtils.isAdmin(params);
        return propagateApproveService.queryList(params);
    }


    /**
     * 审批详情
     *
     * @return
     */
    @RequestMapping("/detail")
    public ResultObject queryDetail() {
        Map<String, Object> params = ReqestParamUtil.getParamsWithUserInfo(request);
        // 是否超级管理员
        params = idAuthUtils.isAdmin(params);
        return propagateApproveService.queryDetail(params);

    }


    /**
     * 审批
     *
     * @return
     */
    @RequestMapping("/doApprove")
    public ResultObject doApprove() {
        Map<String, Object> params = ReqestParamUtil.getParamsWithUserInfo(request);
        // 是否超级管理员
        params = idAuthUtils.isAdmin(params);
        return propagateApproveService.doApprove(params);

    }



}
